<!DOCTYPE html>
<html>
<head>
    

    

    
<!-- Baidu Tongji -->
<script>var _hmt = _hmt || []</script>
<script async src="//hm.baidu.com/hm.js?a7c05ce530152d9866930ef4850ee566"></script>
<!-- End Baidu Tongji -->




    <meta charset="utf-8">
    
    
    
    <title>SSM框架执行流程 | 神奇的鸭鸭の码农库 | 新知识要不断的总结记录成笔记，要多写，多画，能够清晰透彻的将知识讲给别人听，才是达到理解的层次。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#765959">
    
    
    <meta name="keywords" content="SSM">
    <meta name="description" content="今天有公司打电话过来面试，期间问到了SSM框架的执行流程，由于没有什么准备，回答的不太好，所以吃完饭变回来总结总结。 对SSM框架理解Spring有什么用？Spring是一个轻量级的框架，他提供控制反转(IOC)[对象都是从spring容器中拿]，依赖注入(DI)[松耦合，使对象无需知道依赖的来源和具体实现]，面向切面编程(AOP)[松耦合，使业务和逻辑隔离，提高代码重用性，提高开发效率]。这是它">
<meta name="keywords" content="SSM">
<meta property="og:type" content="article">
<meta property="og:title" content="SSM框架执行流程">
<meta property="og:url" content="http://magic_duck.oschina.io/2017/10/24/SSM/index.html">
<meta property="og:site_name" content="神奇的鸭鸭の码农库">
<meta property="og:description" content="今天有公司打电话过来面试，期间问到了SSM框架的执行流程，由于没有什么准备，回答的不太好，所以吃完饭变回来总结总结。 对SSM框架理解Spring有什么用？Spring是一个轻量级的框架，他提供控制反转(IOC)[对象都是从spring容器中拿]，依赖注入(DI)[松耦合，使对象无需知道依赖的来源和具体实现]，面向切面编程(AOP)[松耦合，使业务和逻辑隔离，提高代码重用性，提高开发效率]。这是它">
<meta property="og:image" content="http://om6odecqr.bkt.clouddn.com/springmvc%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B.png">
<meta property="og:updated_time" content="2017-12-05T10:00:29.159Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="SSM框架执行流程">
<meta name="twitter:description" content="今天有公司打电话过来面试，期间问到了SSM框架的执行流程，由于没有什么准备，回答的不太好，所以吃完饭变回来总结总结。 对SSM框架理解Spring有什么用？Spring是一个轻量级的框架，他提供控制反转(IOC)[对象都是从spring容器中拿]，依赖注入(DI)[松耦合，使对象无需知道依赖的来源和具体实现]，面向切面编程(AOP)[松耦合，使业务和逻辑隔离，提高代码重用性，提高开发效率]。这是它">
<meta name="twitter:image" content="http://om6odecqr.bkt.clouddn.com/springmvc%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B.png">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="/css/style.css?v=1.4.3">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu" class="hide" >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">神奇的鸭鸭</h5>
          <a href="mailto:702038338@qq.com" title="702038338@qq.com" class="mail">702038338@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://git.oschina.net/magic_duck" target="_blank" >
                <i class="icon icon-lg icon-gg-circle"></i>
                码云
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://www.zhihu.com/people/shen-qi-de-ya-ya" target="_blank" >
                <i class="icon icon-lg icon-twitter"></i>
                知乎
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404页面测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">SSM框架执行流程</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">SSM框架执行流程</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-10-24T15:20:00.000Z" itemprop="datePublished" class="page-time">
  2017-10-24
</time>


            
        </h5>
    </div>

    

</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#对SSM框架理解"><span class="post-toc-number">1.</span> <span class="post-toc-text">对SSM框架理解</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Spring有什么用？"><span class="post-toc-number">1.1.</span> <span class="post-toc-text">Spring有什么用？</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#SpringMVC有什么用？"><span class="post-toc-number">1.2.</span> <span class="post-toc-text">SpringMVC有什么用？</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Mybatis有什么用？"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">Mybatis有什么用？</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#SSM框架执行流程"><span class="post-toc-number">2.</span> <span class="post-toc-text">SSM框架执行流程</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#项目运行阶段"><span class="post-toc-number">2.1.</span> <span class="post-toc-text">项目运行阶段</span></a></li></ol></li></ol>
        </nav>
    </aside>
    
<article id="post-SSM"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">SSM框架执行流程</h1>
        <div class="post-meta">
            <time class="post-time" title="2017年10月24日 23:20" datetime="2017-10-24T15:20:00.000Z"  itemprop="datePublished">2017-10-24</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <p>今天有公司打电话过来面试，期间问到了SSM框架的执行流程，由于没有什么准备，回答的不太好，所以吃完饭变回来总结总结。</p>
<h2 id="对SSM框架理解"><a href="#对SSM框架理解" class="headerlink" title="对SSM框架理解"></a>对SSM框架理解</h2><h3 id="Spring有什么用？"><a href="#Spring有什么用？" class="headerlink" title="Spring有什么用？"></a>Spring有什么用？</h3><p>Spring是一个轻量级的框架，他提供控制反转(IOC)[对象都是从spring容器中拿]，依赖注入(DI)[松耦合，使对象无需知道依赖的来源和具体实现]，面向切面编程(AOP)[松耦合，使业务和逻辑隔离，提高代码重用性，提高开发效率]。这是它强大的地方，下面来说说它的优点：</p>
<ul>
<li>方便解耦，简化开发<ul>
<li>Spring是一个大工厂(容器)，可以通过Spring将所有对象和依赖关系的维护交给Spring管理。</li>
<li>Spring工厂是用于生成bean的。</li>
</ul>
</li>
<li>AOP编程的支持<ul>
<li>Spring提供面向切面编程，方便实现对程序的权限拦截，运行监控等功能。</li>
</ul>
</li>
<li>声明式事务的支持<ul>
<li>只需要通过配置就可以完成对事务的管理，无需手动编程管理事务。</li>
</ul>
</li>
<li>方便集成各种优秀框架<ul>
<li>Spring提供了对很多优秀框架的支持，例如(hibernate,Mybatis,Struts)等等。</li>
</ul>
</li>
<li>降低JavaEEAPI的使用难度<ul>
<li>对一些难用的API(JDBC，javaMail等)都提供了封装，降低使用难度。</li>
</ul>
</li>
<li>方便测试<ul>
<li>Spring对Junit4支持，可以通过注解方便的测试Spring程序。</li>
</ul>
</li>
</ul>
<h3 id="SpringMVC有什么用？"><a href="#SpringMVC有什么用？" class="headerlink" title="SpringMVC有什么用？"></a>SpringMVC有什么用？</h3><p>SpringMVC属于SpringFramework的后续产品，它使用了MVC架构模式的思想，将web层进行职责解耦，使用SpringMVC目的是简化我们的Web开发的。不使用Struts2的原因是因为Struts2是基于过滤器实现的，SpringMVC是基于servlet实现的，效率会更高。同时Struts2是多例的(基于属性封装)，每个请求都会创建多个对象，而SpringMVC是单例的(基于方法封装)，消耗资源也会更低。</p>
<h3 id="Mybatis有什么用？"><a href="#Mybatis有什么用？" class="headerlink" title="Mybatis有什么用？"></a>Mybatis有什么用？</h3><p>mybatis是一个用来封装jdbc的持久层框架，mybatis让程序员只关注sql本身，而不用去关注如连接的创建，statement的创建这些操作，mybatis是一个不完全的ORM框架，它不能支持数据库无关系(数据库发生改变，要写多套代码进行支持，移植性没有hibernate好)，但由于直接编写sql语句，可以直接对sql进行性能优化，灵活多变，代码维护性更好。</p>
<h2 id="SSM框架执行流程"><a href="#SSM框架执行流程" class="headerlink" title="SSM框架执行流程"></a>SSM框架执行流程</h2><h3 id="项目运行阶段"><a href="#项目运行阶段" class="headerlink" title="项目运行阶段"></a>项目运行阶段</h3><p><strong>其实指的就是SpringMVC的执行流程，先注释以下名词：</strong></p>
<ul>
<li>前端控制器 DispatcherServlet</li>
<li>处理器映射器 HandlerMapping</li>
<li>处理执行链 HandlerExecutionChain</li>
<li>处理器适配器 HandlerAdapter</li>
<li>模型和视图 ModelAndView</li>
<li>视图解析器 ViewResolver</li>
</ul>
<p><strong>下面描述执行流程：</strong></p>
<ul>
<li>1 用户发送请求到DispatcherServlet</li>
<li>2 DispatcherServlet请求HandlerMapping寻找action(Handler)</li>
<li>3 HandlerMapping找到Action把请求映射成HandlerExecutionChain返回给DispatcherServlet。其结构类似：chain{拦截器 Action 拦截器}</li>
<li>4 DispatcherServlet拿到执行链，请求HandlerAdapter执行Action</li>
<li>5 HandlerAdapter执行Action(调用业务层方法，返回执行结果)</li>
<li>6 Handler执行完后给HandlerAdapter返回ModelAndView</li>
<li>7 HandlerAdapter向DispatcherServlet返回ModelAndVie</li>
<li>8 DispatcherServlet请求ViewResolver解析视图</li>
<li>9 ViewResolver将解析的视图返回给DispatcherServlet</li>
<li>10 DispatcherServlet进行视图渲染(将模型数据绑定到request域中[这样才能使用jstl标签解析数据])</li>
<li>11 DispatcherServlet向用户响应结果</li>
</ul>
<p><strong>图片参考：</strong><br><img src="http://om6odecqr.bkt.clouddn.com/springmvc%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B.png" alt="1"></p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-12-05T10:00:29.159Z" itemprop="dateUpdated">2017年12月5日 18:00</time>
</span><br>


        如要转载请注明出处：<a href="/2017/10/24/SSM/" target="_blank" rel="external">http://magic_duck.oschina.io/2017/10/24/SSM/</a>
    </div>
    <footer>
        <a href="http://magic_duck.oschina.io">
            <img src="/img/avatar.jpg" alt="神奇的鸭鸭">
            神奇的鸭鸭
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/SSM/">SSM</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/10/24/SSM/&title=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/10/24/SSM/&title=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/10/24/SSM/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/10/24/SSM/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/10/24/SSM/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/11/07/java_enhance4_四舍五入非小事/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">java提高篇(四) 四舍五入非小事</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/10/23/java_enhance3_多态/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">java提高篇(三) 理解java的三大特性之多态</h4>
      </a>
    </div>
  
</nav>



    







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        我只要一角钱~ ~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.png" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            <span><a href="" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            <span>博客内容遵循 <a href="http://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">知识共享 署名 - 非商业性 - 相同方式共享 4.0协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://git.oschina.net/z77z" target="_blank">邹海清</a></span>
            <span>神奇的鸭鸭の码农库 &copy; 2017</span>
        </p>
    </div>
</footer>

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://magic_duck.oschina.io/2017/10/24/SSM/&title=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&pic=http://magic_duck.oschina.io/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://magic_duck.oschina.io/2017/10/24/SSM/&title=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&source=" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://magic_duck.oschina.io/2017/10/24/SSM/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《SSM框架执行流程》 — 神奇的鸭鸭の码农库&url=http://magic_duck.oschina.io/2017/10/24/SSM/&via=http://magic_duck.oschina.io" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://magic_duck.oschina.io/2017/10/24/SSM/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="//api.qrserver.com/v1/create-qr-code/?data=http://magic_duck.oschina.io/2017/10/24/SSM/" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



lazyScripts.push('//s95.cnzz.com/z_stat.php?id=1261081671&web_id=1261081671')

</script>

<script src="/js/main.min.js?v=1.4.3"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="/js/search.min.js?v=1.4.3" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>


</body>
</html>
